package com.sn.pw.common.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.gitee.sunchenbin.mybatis.actable.annotation.*;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 数据库自动创建公共类
 */
@Data
public class BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.AUTO)//指定数据库自增
    @IsAutoIncrement
    @ColumnComment("主键id")
    @IsKey
    private Long id;

    @TableField("is_delete")
    @ColumnType(MySqlTypeConstant.TINYINT)
    @ColumnComment("逻辑删除字段 0未删除 1删除")
    @DefaultValue("0")
    private boolean deleted;

    @TableField(value = "create_time",fill = FieldFill.INSERT)
    @ColumnType(MySqlTypeConstant.TIMESTAMP)
    @ColumnComment("创建时间")
    private Date createTime;

    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    @ColumnType(MySqlTypeConstant.TIMESTAMP)
    @ColumnComment("更新时间")
    private Date updateTime;

    @TableField(value = "creator",fill = FieldFill.INSERT)
    @ColumnType(MySqlTypeConstant.VARCHAR)
    @ColumnComment("创建者")
    private String creator;

    @TableField(value = "updater",fill = FieldFill.INSERT_UPDATE)
    @ColumnType(MySqlTypeConstant.VARCHAR)
    @ColumnComment("更新者")
    private String updater;

    @TableField(value = "create_by",fill = FieldFill.INSERT)
    @ColumnType(MySqlTypeConstant.BIGINT)
    @ColumnComment("创建者id")
    private Long createBy;

    @TableField(value = "update_by",fill = FieldFill.INSERT_UPDATE)
    @ColumnType(MySqlTypeConstant.BIGINT)
    @ColumnComment("更新者id")
    private Long updateBy;


}
